package com.gzx.plugin.tjzy.modular.supplier.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.supplier.bo.GzxSupplierAddOrEditBo;
import com.gzx.plugin.tjzy.modular.supplier.bo.GzxSupplierQueryBo;
import com.gzx.plugin.tjzy.modular.supplier.service.GzxSupplierService;
import com.gzx.plugin.tjzy.modular.supplier.vo.GzxSupplierVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/3/6 18:42
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/tjzy/supplier")
public class GzxSupplierController {

    private final GzxSupplierService supplierService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxSupplierVo>> pageList(@RequestBody GzxSupplierQueryBo supplierQueryBo) {
        return CommonResult.data(supplierService.pageList(supplierQueryBo));
    }

    @PostMapping("/addOrEdit")
    @CommonLog("供应商新增")
    public CommonResult<Void> addOrEdit(@RequestBody GzxSupplierAddOrEditBo supplierAddOrEditBo) {
        supplierService.addOrEdit(supplierAddOrEditBo);
        return CommonResult.ok();
    }

    @GetMapping("/list")
    public CommonResult<List<GzxSupplierVo>> list() {
        return CommonResult.data(supplierService.list());
    }

    @GetMapping("/del/{id}")
    public CommonResult<Void> del(@PathVariable Long id) {
        supplierService.del(id);
        return CommonResult.ok();
    }
}
